Prev Next |
Masters separate Item creation logic from Template structure. The separation of Template from Master allows Templates to be used for a greater variety of purposes, which can result in fewer Templates requiring maintenance.
In general each Master is associated with a Template, and the Fields defined on the Template define the fields which appear on the Master.
In object-oriented programming terms a Sitecore Master is most like a constructor, defining default field values, layout, security and other settings applied to new Items created from the Master. Masters function like on-insert triggers in a relational database.
When a user creates a new Item based on a Master, Sitecore basically copies that Master to the location of the new Item and expands certain tokens in the Master such as $name (the name entered by the user when creating the new Item), $parentname (the name of the parent of the new item), $id (the GUID of the new item) and $parentid (the GUID of the parent of the new Item). Because changes do not propagate through the system when Masters change, in general layout settings should not be set on Masters but rather on Templates (from which such settings are inherited). If the “Copy Parent Rights” checkbox is selected on the Master, security from the parent will be applied to the new Item; otherwise the security settings specified on the Master will be copied with the rest of the data in the Master.
Masters are used to:
- Cause Templates to behave differently in different contexts (by associating multiple Masters with a single Template).
- Default Field values, security, layout and other data when new Items are created, or cause new Items created from the Master to override layout and other settings configured on the Template. Simply populate the Master as an individual Item would be populated; these values will be copied to any new Items created based on the Master.
- Create default children for new Items, for instance automatically creating pricing and screenshots items under new products when they are created. To implement such a Master Hierarchy, simply create the additional Items under the Master.
- Restrict the types of Items users can create under existing Items. To implement, configure the list of allowed Masters in the Masters Section of the existing Items.
- Restrict the types of Items users can create under new Items based on the Master. To implement, configure the list of allowed Masters in the Masters Section of the Master; these values will be copied to any new Item created based on the Master. A Master can be associated with itself, such as a generic Page Master referencing itself in its Masters Section, allowing new Pages to be created under any new Items based on this Master.
As an example of when multiple Masters for a single Template might be useful, consider a section of the website that has at least two types of users: anonymous users and authenticated members of various audience segments. A section of this website contains many Items of the same data type (based on the same Template); most are available to anonymous users but some are only available to authenticated members of the various groups. To make it easier for CMS users to add both items which are available to anonymous users and items which are available to members of the various groups, one master would be implemented with permissions open to anonymous users, another with permissions set such that only members of a specific group can view that content. When a user creates a new Item from a Master, they will choose either the anonymous Master or the restricted Master – in this way they do not have to explicitly set permissions on the new Items.
Prev Next